//
//  MyButton.m
//  ZeroBuy
//
//  Copyright (c) 2015年 ++. All rights reserved.
//

#import "MyButton.h"

@interface MyButton()

@property (nonatomic, copy) buttonBlock block;

@end
@implementation MyButton


+(MyButton *)buttonWithType:(UIButtonType)type frame:(CGRect)frame title:(NSString *)title bgImage:(NSString *)bgImage image:(NSString *)image selectedImage:(NSString *)selectedImage block:(buttonBlock)block{
    MyButton *button = [MyButton buttonWithType:type];
    
    [button setTitle:title forState:UIControlStateNormal];
    button.frame = frame;
    
    [button setBackgroundImage:[UIImage imageNamed:bgImage] forState:UIControlStateNormal];
    
    [button setImage:[UIImage imageNamed:image] forState:UIControlStateNormal];
    
    [button setImage:[UIImage imageNamed:selectedImage] forState:UIControlStateSelected];
    [button addTarget:button action:@selector(buttonClick:) forControlEvents:UIControlEventTouchUpInside];
    
    button.block = block;
    
    return button;
}

-(void)buttonClick:(MyButton *)button{
    
    
    self.block();
}
-(void)setLeftImageView:(UIImageView *)leftImageView{
    
    _leftImageView = leftImageView;
    
    [self addSubview:leftImageView];
 
}

@end

